/**  
 * @Title:  JDKProxyTest.java   
 * @Package ProxyByHand   
 * @Description:    TODO   
 * @author: hezhiqin     
 * @date:   2019年4月1日 下午5:16:01   
 */  
package ProxyByHand;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;

import Dongtai.JDKMeipo;
import Dongtai.SingleDog;
import Person.Person;
import sun.misc.ProxyGenerator;

/**   
 * @ClassName:  JDKProxyTest   
 * @Description:TODO(这里用一句话描述这个类的作用)   
 * @author: hezhiqin
 * @date:   2019年4月1日 下午5:16:01   
 *      
 */
public class JDKProxyTest {
	public static void main(String[] args) {
		
		try {
			Person obj = (Person)new JDKMeipo().getInstance(new SingleDog());
			
			obj.findLove();
			//通过反编译工具可以查看源代码
			byte [] bytes = ProxyGenerator.generateProxyClass("$Proxy0",new Class[]{Person.class});
			FileOutputStream os = new FileOutputStream("C://uploadfile//$Proxy0.class");
			os.write(bytes);
			os.close();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
